import { readFileSync } from "fs";
import { resolve } from "path";

const  buf =readFileSync(resolve(__dirname,'./0a4d7f88-17f5-4a37-8b09-6ab9d63a45b6.bin'))

var BYTE_CODE;
(function(BYTE_CODE) {
  BYTE_CODE[BYTE_CODE["LOAD_CONST"] = 0] = "LOAD_CONST";
  BYTE_CODE[BYTE_CODE["MAKE_FUNCTION"] = 1] = "MAKE_FUNCTION";
  BYTE_CODE[BYTE_CODE["STORE_NAME"] = 2] = "STORE_NAME";
  BYTE_CODE[BYTE_CODE["LOAD_NAME"] = 3] = "LOAD_NAME";
  BYTE_CODE[BYTE_CODE["CALL_FUNCTION"] = 4] = "CALL_FUNCTION";
  BYTE_CODE[BYTE_CODE["COMPARE_OP"] = 5] = "COMPARE_OP";
  BYTE_CODE[BYTE_CODE["POP_JUMP_IF_FALSE"] = 6] = "POP_JUMP_IF_FALSE";
  BYTE_CODE[BYTE_CODE["POP_TOP"] = 7] = "POP_TOP";
  BYTE_CODE[BYTE_CODE["JUMP_FORWARD"] = 8] = "JUMP_FORWARD";
  BYTE_CODE[BYTE_CODE["JUMP_ABSOLUTE"] = 9] = "JUMP_ABSOLUTE";
  BYTE_CODE[BYTE_CODE["RETURN_VALUE"] = 10] = "RETURN_VALUE";
  BYTE_CODE[BYTE_CODE["LOAD_GLOBAL"] = 11] = "LOAD_GLOBAL";
  BYTE_CODE[BYTE_CODE["EXTENDED_ARG"] = 12] = "EXTENDED_ARG";
  BYTE_CODE[BYTE_CODE["BUILD_LIST"] = 13] = "BUILD_LIST";
  BYTE_CODE[BYTE_CODE["POP_JUMP_IF_TRUE"] = 14] = "POP_JUMP_IF_TRUE";
  BYTE_CODE[BYTE_CODE["STORE_FAST"] = 15] = "STORE_FAST";
  BYTE_CODE[BYTE_CODE["LOAD_FAST"] = 16] = "LOAD_FAST";
  BYTE_CODE[BYTE_CODE["BINARY_ADD"] = 17] = "BINARY_ADD";
  BYTE_CODE[BYTE_CODE["BINARY_SUBTRACT"] = 18] = "BINARY_SUBTRACT";
  BYTE_CODE[BYTE_CODE["BINARY_MULTIPLY"] = 19] = "BINARY_MULTIPLY";
  BYTE_CODE[BYTE_CODE["STORE_GLOBAL"] = 20] = "STORE_GLOBAL";
  BYTE_CODE[BYTE_CODE["GET_ITER"] = 21] = "GET_ITER";
  BYTE_CODE[BYTE_CODE["FOR_ITER"] = 22] = "FOR_ITER";
  BYTE_CODE[BYTE_CODE["INPLACE_ADD"] = 23] = "INPLACE_ADD";
  BYTE_CODE[BYTE_CODE["BINARY_SUBSCR"] = 24] = "BINARY_SUBSCR";
  BYTE_CODE[BYTE_CODE["STORE_SUBSCR"] = 25] = "STORE_SUBSCR";
  BYTE_CODE[BYTE_CODE["DUP_TOP_TWO"] = 26] = "DUP_TOP_TWO";
  BYTE_CODE[BYTE_CODE["INPLACE_SUBTRACT"] = 27] = "INPLACE_SUBTRACT";
  BYTE_CODE[BYTE_CODE["ROT_THREE"] = 28] = "ROT_THREE";
  BYTE_CODE[BYTE_CODE["STORE_ATTR"] = 29] = "STORE_ATTR";
  BYTE_CODE[BYTE_CODE["LOAD_ATTR"] = 30] = "LOAD_ATTR";
  BYTE_CODE[BYTE_CODE["BUILD_CONST_KEY_MAP"] = 31] = "BUILD_CONST_KEY_MAP";
  BYTE_CODE[BYTE_CODE["DUP_TOP"] = 32] = "DUP_TOP";
  BYTE_CODE[BYTE_CODE["ROT_TWO"] = 33] = "ROT_TWO";
  BYTE_CODE[BYTE_CODE["BUILD_MAP"] = 34] = "BUILD_MAP";
  BYTE_CODE[BYTE_CODE["JUMP_IF_FALSE_OR_POP"] = 35] = "JUMP_IF_FALSE_OR_POP";
  BYTE_CODE[BYTE_CODE["LOAD_METHOD"] = 36] = "LOAD_METHOD";
  BYTE_CODE[BYTE_CODE["CALL_METHOD"] = 37] = "CALL_METHOD";
  BYTE_CODE[BYTE_CODE["BINARY_MODULO"] = 38] = "BINARY_MODULO";
  BYTE_CODE[BYTE_CODE["JUMP_IF_TRUE_OR_POP"] = 39] = "JUMP_IF_TRUE_OR_POP";
  BYTE_CODE[BYTE_CODE["UNARY_NEGATIVE"] = 40] = "UNARY_NEGATIVE";
  BYTE_CODE[BYTE_CODE["BINARY_FLOOR_DIVIDE"] = 41] = "BINARY_FLOOR_DIVIDE";
  BYTE_CODE[BYTE_CODE["IMPORT_NAME"] = 42] = "IMPORT_NAME";
  BYTE_CODE[BYTE_CODE["IMPORT_STAR"] = 43] = "IMPORT_STAR";
  BYTE_CODE[BYTE_CODE["DELETE_SUBSCR"] = 44] = "DELETE_SUBSCR";
  BYTE_CODE[BYTE_CODE["BINARY_TRUE_DIVIDE"] = 45] = "BINARY_TRUE_DIVIDE";
  BYTE_CODE[BYTE_CODE["UNARY_NOT"] = 46] = "UNARY_NOT";
  BYTE_CODE[BYTE_CODE["NOP"] = 47] = "NOP";
  BYTE_CODE[BYTE_CODE["LIST_EXTEND"] = 48] = "LIST_EXTEND";
  BYTE_CODE[BYTE_CODE["BUILD_TUPLE"] = 49] = "BUILD_TUPLE";
  BYTE_CODE[BYTE_CODE["LIST_APPEND"] = 50] = "LIST_APPEND";
  BYTE_CODE[BYTE_CODE["FORMAT_VALUE"] = 51] = "FORMAT_VALUE";
  BYTE_CODE[BYTE_CODE["BUILD_STRING"] = 52] = "BUILD_STRING";
})(BYTE_CODE || (BYTE_CODE = {}));

var PyType;
(function(PyType) {
  PyType[PyType["Function"] = 0] = "Function";
  PyType[PyType["JSFunction"] = 1] = "JSFunction";
  PyType[PyType["Range"] = 2] = "Range";
  PyType[PyType["Iterator"] = 3] = "Iterator";
  PyType[PyType["Address"] = 4] = "Address";
  PyType[PyType["Tuple"] = 5] = "Tuple";
  PyType[PyType["Method_Function"] = 6] = "Method_Function";
})(PyType || (PyType = {}));

    var __values = function(o) {
      var s = "function" === typeof Symbol && Symbol.iterator, m = s && o[s], i = 0;
      if (m) return m.call(o);
      if (o && "number" === typeof o.length) return {
        next: function() {
          o && i >= o.length && (o = void 0);
          return {
            value: o && o[i++],
            done: !o
          };
        }
      };
      throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    };

    var Tool = function() {
      function Tool() {}
      Tool_1 = Tool;
      Tool.len = function(obj) {
        var n = 0;
        for (var key in obj) n++;
        return n;
      };
      Tool.clone = function(obj) {
        if (null == obj || "object" != typeof obj) return obj;
        if (obj instanceof cc.Node) return obj;
        if (obj instanceof Array) {
          var copy = [];
          for (var i = 0, len = obj.length; i < len; ++i) copy[i] = Tool_1.clone(obj[i]);
          return copy;
        }
        if (obj instanceof Object) {
          var copy = {};
          for (var attr in obj) obj.hasOwnProperty(attr) && (copy[attr] = Tool_1.clone(obj[attr]));
          return copy;
        }
      };
      Tool.random = function(a, b) {
        if (a == b) return a;
        var sub = b + 1 - a;
        return Math.floor(Math.random() * (100 + sub)) % sub + a;
      };
      var Tool_1;
      return Tool;
    }();


var PyManager = function() {
   function PyManager(helper) {
     var _this = this;
     this._index = 0;
     this._buffer = null;
     this._funcs = {};
     this._module = {};
     this._yieldCount = 0;
     this._running = true;
     this._state1 = false;
     this._ex_param = 0;
     this.reset();
     this._helper = helper;
     this.add_function("print", function(manager) {
       var e_1, _a;
       var vs = manager.params();
       try {
         for (var vs_1 = __values(vs), vs_1_1 = vs_1.next(); !vs_1_1.done; vs_1_1 = vs_1.next()) var v = vs_1_1.value;
       } catch (e_1_1) {
         e_1 = {
           error: e_1_1
         };
       } finally {
         try {
           vs_1_1 && !vs_1_1.done && (_a = vs_1.return) && _a.call(vs_1);
         } finally {
           if (e_1) throw e_1.error;
         }
       }
     });
     this.add_function("range", function(manager) {
       var params = manager.params();
       return {
         __pyType: PyType.Range,
         start: params[0],
         end: params[1]
       };
     });
     this.add_function("len", function(manager) {
       var params = manager.params();
       var param = params[0];
       return param.length;
     }, true);
     this.add_function("call", function(manager) {
       var name = manager.params()[0];
       _this.call(name);
     }, false);
     this.add_function("hasFunc", this.hasFunc.bind(this));
     this.add_var("Math", Math);
     this.add_var("System", this);
     this.add_function("int", function(manager) {
       var name = manager.params()[0];
       return Number(name);
     }, true);
     this.add_function("str", function(manager) {
       var name = manager.params()[0];
       return String(name);
     }, true);
     this.add_function("random", function(manager) {
       var params = manager.params();
       return Tool_1.default.random(params[0], params[1]);
     }, true);
     this.add_var("list", "list");
   }
   PyManager.prototype.running = function() {
     return this._running;
   };
   PyManager.prototype._setIsPause = function() {
     this._state1 = true;
   };
   PyManager.prototype.destory = function() {
     this._running = false;
   };
   PyManager.prototype.pauseState = function() {
     return 0 != this._yieldCount;
   };
   PyManager.prototype.pause = function() {
     this._yieldCount++;
   };
   PyManager.prototype.resume = function() {
     this._yieldCount--;
     if (0 == this._yieldCount && this._state1) {
       this._state1 = false;
       this._helper.next();
     }
   };
   PyManager.prototype.setRet = function(v) {
     this._return = v;
   };
   PyManager.prototype.ret = function() {
     return this._return;
   };
   PyManager.prototype.setArgv = function(argv) {
     this._argv = argv;
   };
   PyManager.prototype.argv = function() {
     return this._argv;
   };
   PyManager.prototype.params = function() {
     return this._params;
   };
   PyManager.prototype.reset = function() {
     this._stack = [];
     this._funcStack = [];
     this._global = {};
     this._yieldCount = 0;
     this._running = true;
     this._state1 = false;
     this._return = void 0;
     this._argv = void 0;
   };
   PyManager.prototype.setHelper = function(helper) {
     this._helper = helper;
   };
   PyManager.prototype.push = function(data) {
     this._stack.push(data);
   };
   PyManager.prototype.add_function = function(name, func, hasRet) {
     void 0 === hasRet && (hasRet = true);
     this._module[name] = {
       __pyType: PyType.JSFunction,
       func: func,
       hasRet: hasRet
     };
   };
   PyManager.prototype.add_var = function(name, value) {
     this._module[name] = value;
   };
   PyManager.prototype.stackTop = function() {
     return this._stack[this._stack.length - 1];
   };
   PyManager.prototype.haveFunction = function(funcName) {
     return this._funcs.hasOwnProperty(funcName);
   };
   PyManager.prototype.loadBin = function(bin) {
     var err = 0;
     do {
       var byteary = bin["_buffer"];
       this._buffer = new Uint8Array(byteary);
       var header = this.readString();
       if (!header.endsWith("python")) {
         err = 1;
         break;
       }
       var count = this.readInteger();
       for (var i = 0; i < count; i++) {
         var name = this.readString();
         var consts2 = [];
         var n = this.readInteger();
         for (var j = 0; j < n; j++) {
           var value = this.readString();
           var c = value.charCodeAt(0);
           if (60 == c) {
             consts2.push({
               __pyType: PyType.Address,
               address: value.substring(1, value.length - 1)
             });
             continue;
           }
           if (40 == c) {
             value = value.replace(/\s/g, "");
             value = value.replace(/\(/g, "[");
             value = value.replace(/\)/g, "]");
             value = value.replace(/,\]/g, "]");
             value = value.replace(/'/g, '"');
             consts2.push({
               __pyType: PyType.Tuple,
               tuple: JSON.parse(value)
             });
             continue;
           }
           if (39 == c) {
             consts2.push(value.substring(1, value.length - 1));
             continue;
           }
           if (45 == c || c >= 48 && c <= 57) {
             consts2.push(Number(value));
             continue;
           }
           switch (value) {
            case "None":
             consts2.push(void 0);
             break;

            case "True":
             consts2.push(true);
             break;

            case "False":
             consts2.push(false);
           }
         }
         var names = [];
         n = this.readInteger();
         for (var j = 0; j < n; j++) names.push(this.readString());
         var globals = [];
         n = this.readInteger();
         for (var j = 0; j < n; j++) globals.push(this.readString());
         var lines = {};
         n = this.readInteger();
         for (var j = 0; j < n; j++) {
           var k = this.readInteger();
           var v = this.readInteger();
           lines[String(k)] = v;
         }
         n = this.readInteger();
         this._funcs[name] = {
           consts: consts2,
           names: names,
           globals: globals,
           lines: lines,
           bytes: this._index
         };
         this._index += n;
       }
     } while (false);
     return err;
   };
   PyManager.prototype.call = function(name, params) {
     void 0 === params && (params = []);
     this._funcStack.push({
       name: name,
       fast: params,
       func: this._funcs[name],
       ip: 0
     });
   };
   PyManager.prototype.hasFunc = function(manager) {
     var name = manager.params()[0];
     if (!this._funcs.hasOwnProperty(name)) return false;
     return true;
   };
   PyManager.prototype.getExArg = function(ip) {
     var ret = this._buffer[ip + 1];
     if (0 != this._ex_param) {
       ret = this._ex_param << 8 | ret;
       this._ex_param = 0;
     }
     return ret;
   };
   PyManager.prototype.run = function() {
     var e_2, _a, e_3, _b, e_4, _c;
     var function3 = this._funcStack[this._funcStack.length - 1];
     var curFunc = function3.func;
     var CS = curFunc.bytes;
     var ip = CS + function3.ip;
     var byte = this._buffer[ip];
     function3.ip += 2;
     switch (byte) {
      case BYTE_CODE.LOAD_CONST:
       var idx = this.getExArg(ip);
       var param = curFunc.consts[idx];
       this._stack.push(param);
       break;

      case BYTE_CODE.MAKE_FUNCTION:
       var name = this._stack.pop();
       var address = this._stack.pop();
       var flag = this.getExArg(ip);
       var annotations = void 0;
       4 & flag && (annotations = this._stack.pop());
       var defaults = void 0;
       1 & flag && (defaults = this._stack.pop());
       this._stack.push({
         __pyType: PyType.Function,
         name: name,
         address: address.address,
         annotations: annotations,
         defaults: defaults
       });
       break;

      case BYTE_CODE.STORE_NAME:
       var idx = this.getExArg(ip);
       var name = curFunc.names[idx];
       this._global[name] = this._stack.pop();
       break;

      case BYTE_CODE.LOAD_GLOBAL:
       var idx = this.getExArg(ip);
       var name = curFunc.globals[idx];
       this._global.hasOwnProperty(name) ? this._stack.push(this._global[name]) : this._stack.push(this._module[name]);
       break;

      case BYTE_CODE.LOAD_NAME:
       var idx = this.getExArg(ip);
       var name = curFunc.names[idx];
       this._global.hasOwnProperty(name) ? this._stack.push(this._global[name]) : this._stack.push(this._module[name]);
       break;

      case BYTE_CODE.CALL_FUNCTION:
       var param_n = this.getExArg(ip);
       var args = [];
       for (var i = 0; i < param_n; i++) args.unshift(this._stack.pop());
       var func = this._stack.pop();
       if (func.hasOwnProperty("__pyType")) switch (func.__pyType) {
        case PyType.Function:
         this._funcStack.push({
           name: func.name,
           fast: args,
           func: this._funcs[func.address],
           ip: 0,
           defaults: func.defaults
         });
         break;

        case PyType.JSFunction:
         this._params = args;
         var ret_1 = func.func(this);
         this._params = void 0;
         func.hasRet && this._stack.push(ret_1);
       } else {
         var obj = {
           __proto__: func.prototype
         };
         func.apply(obj, args);
         this._stack.push(obj);
       }
       break;

      case BYTE_CODE.COMPARE_OP:
       var r = this._stack.pop();
       var l = this._stack.pop();
       var lt = typeof l;
       var rt = typeof r;
       var oper = this.getExArg(ip);
       var ret_2 = false;
       if ("number" == lt && "number" == rt) switch (oper) {
        case 0:
         ret_2 = l < r;
         break;

        case 1:
         ret_2 = l <= r;
         break;

        case 2:
         ret_2 = l == r;
         break;

        case 3:
         ret_2 = l != r;
         break;

        case 4:
         ret_2 = l > r;
         break;

        case 5:
         ret_2 = l >= r;
       } else switch (oper) {
        case 2:
         ret_2 = l == r;
         break;

        case 3:
         ret_2 = l != r;
       }
       this._stack.push(ret_2);
       break;

      case BYTE_CODE.JUMP_IF_TRUE_OR_POP:
       var val = this._stack.pop();
       var ip2 = this.getExArg(ip);
       if (val) {
         function3.ip = ip2 << 1;
         this._stack.push(val);
       }
       break;

      case BYTE_CODE.POP_JUMP_IF_TRUE:
       var val = this._stack.pop();
       var ip2 = this.getExArg(ip);
       val && (function3.ip = ip2 << 1);
       break;

      case BYTE_CODE.JUMP_IF_FALSE_OR_POP:
       var val = this._stack.pop();
       var ip2 = this.getExArg(ip);
       if (!val) {
         function3.ip = ip2 << 1;
         this._stack.push(val);
       }
       break;

      case BYTE_CODE.POP_JUMP_IF_FALSE:
       var val = this._stack.pop();
       var ip2 = this.getExArg(ip);
       val || (function3.ip = ip2 << 1);
       break;

      case BYTE_CODE.JUMP_ABSOLUTE:
       function3.ip = this.getExArg(ip) << 1;
       break;

      case BYTE_CODE.RETURN_VALUE:
       this._funcStack.pop();
       this._running = this._funcStack.length > 0;
       break;

      case BYTE_CODE.EXTENDED_ARG:
       this._ex_param = this._buffer[ip + 1];
       break;

      case BYTE_CODE.BUILD_LIST:
       var n = this.getExArg(ip);
       var list7 = [];
       for (var i = 0; i < n; i++) {
         var l3 = this._stack.pop();
         list7.unshift(l3);
       }
       this._stack.push(list7);
       break;

      case BYTE_CODE.LIST_APPEND:
      case BYTE_CODE.LIST_EXTEND:
       var n = this.getExArg(ip);
       var list = [];
       for (var i = 0; i < n; i++) list.push(this._stack.pop());
       var ary = this.stackTop();
       try {
         for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
           var v = list_1_1.value;
           if (v.hasOwnProperty("__pyType") && v.__pyType == PyType.Tuple) {
             try {
               for (var _d = (e_3 = void 0, __values(v.tuple)), _e = _d.next(); !_e.done; _e = _d.next()) {
                 var v2 = _e.value;
                 ary.push(v2);
               }
             } catch (e_3_1) {
               e_3 = {
                 error: e_3_1
               };
             } finally {
               try {
                 _e && !_e.done && (_b = _d.return) && _b.call(_d);
               } finally {
                 if (e_3) throw e_3.error;
               }
             }
             continue;
           }
           ary.push(v);
         }
       } catch (e_2_1) {
         e_2 = {
           error: e_2_1
         };
       } finally {
         try {
           list_1_1 && !list_1_1.done && (_a = list_1.return) && _a.call(list_1);
         } finally {
           if (e_2) throw e_2.error;
         }
       }
       break;

      case BYTE_CODE.STORE_FAST:
       var idx = this.getExArg(ip);
       function3.fast[idx] = this._stack.pop();
       break;

      case BYTE_CODE.LOAD_FAST:
       var idx = this.getExArg(ip);
       var fast = function3.fast;
       this._stack.push(fast[idx]);
       break;

      case BYTE_CODE.INPLACE_SUBTRACT:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l - r);
       break;

      case BYTE_CODE.BINARY_MODULO:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l % r);
       break;

      case BYTE_CODE.BINARY_ADD:
      case BYTE_CODE.INPLACE_ADD:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l + r);
       break;

      case BYTE_CODE.BINARY_SUBTRACT:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l - r);
       break;

      case BYTE_CODE.BINARY_MULTIPLY:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l * r);
       break;

      case BYTE_CODE.BINARY_FLOOR_DIVIDE:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(Math.floor(l / r));
       break;

      case BYTE_CODE.BINARY_TRUE_DIVIDE:
       var r = this._stack.pop();
       var l = this._stack.pop();
       this._stack.push(l / r);
       break;

      case BYTE_CODE.POP_TOP:
       this._stack.pop();
       break;

      case BYTE_CODE.JUMP_FORWARD:
       var idx = this.getExArg(ip) << 1;
       function3.ip += idx;
       break;

      case BYTE_CODE.GET_ITER:
       var data = this._stack.pop();
       if (data instanceof Array) {
         this._stack.push({
           __pyType: PyType.Iterator,
           obj: data,
           idx: 0
         });
         break;
       }
       if (data.hasOwnProperty("__pyType")) {
         this._stack.push({
           __pyType: PyType.Iterator,
           obj: data,
           idx: 0
         });
         break;
       }
       var keys = [];
       for (var key in data) keys.push(key);
       this._stack.push({
         __pyType: PyType.Iterator,
         obj: keys,
         idx: 0
       });
       break;

      case BYTE_CODE.DELETE_SUBSCR:
       var pro1 = this._stack.pop();
       var obj = this._stack.pop();
       delete obj[pro1];
       break;

      case BYTE_CODE.BINARY_SUBSCR:
       var pro1 = this._stack.pop();
       var obj = this._stack.pop();
       this._stack.push(obj[pro1]);
       break;

      case BYTE_CODE.FOR_ITER:
       var ret = void 0;
       do {
         var iter = this._stack[this._stack.length - 1];
         var obj = iter.obj;
         var idx = iter.idx;
         if (obj instanceof Array) {
           idx < obj.length && (ret = obj[idx]);
           iter.idx++;
           break;
         }
         var start = obj.start;
         var end = obj.end;
         var cur = start + idx;
         if (cur < end) {
           ret = cur;
           iter.idx++;
           break;
         }
       } while (false);
       if (void 0 != ret) this._stack.push(ret); else {
         this._stack.pop();
         var ex = this.getExArg(ip) << 1;
         function3.ip += ex;
       }
       break;

      case BYTE_CODE.LOAD_ATTR:
       var obj = this._stack.pop();
       var idx = this.getExArg(ip);
       var attr = curFunc.globals[idx];
       this._stack.push(obj[attr]);
       break;

      case BYTE_CODE.STORE_ATTR:
       var obj = this._stack.pop();
       var val = this._stack.pop();
       var idx = this.getExArg(ip);
       var attr = curFunc.globals[idx];
       obj[attr] = val;
       break;

      case BYTE_CODE.STORE_SUBSCR:
       var pro1 = this._stack.pop();
       var obj = this._stack.pop();
       var v = this._stack.pop();
       obj[pro1] = v;
       break;

      case BYTE_CODE.DUP_TOP:
       var arg0_1 = this._stack[this._stack.length - 1];
       this._stack.push(arg0_1);
       break;

      case BYTE_CODE.DUP_TOP_TWO:
       var arg0 = this._stack[this._stack.length - 2];
       var arg1 = this._stack[this._stack.length - 1];
       this._stack.push(arg0);
       this._stack.push(arg1);
       break;

      case BYTE_CODE.ROT_THREE:
       var len = this._stack.length;
       var top = this._stack[len - 1];
       var second = this._stack[len - 2];
       var third = this._stack[len - 3];
       this._stack[len - 1] = second;
       this._stack[len - 2] = third;
       this._stack[len - 3] = top;
       break;

      case BYTE_CODE.ROT_TWO:
       var len = this._stack.length;
       var top = this._stack[len - 1];
       var second = this._stack[len - 2];
       this._stack[len - 1] = second;
       this._stack[len - 2] = top;
       break;

      case BYTE_CODE.BUILD_MAP:
       var n = this.getExArg(ip);
       var map = {};
       for (var i = 0; i < n; i++) {
         var v = this._stack.pop();
         var k = this._stack.pop();
         map[k] = v;
       }
       this._stack.push(map);
       break;

      case BYTE_CODE.BUILD_CONST_KEY_MAP:
       var argn = this.getExArg(ip);
       var keys = this._stack.pop();
       keys = keys.tuple;
       var vs = [];
       for (var i_1 = 0; i_1 < argn; i_1++) vs.unshift(this._stack.pop());
       var map = {};
       var i = 0;
       try {
         for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
           var k = keys_1_1.value;
           map[k] = vs[i];
           i++;
         }
       } catch (e_4_1) {
         e_4 = {
           error: e_4_1
         };
       } finally {
         try {
           keys_1_1 && !keys_1_1.done && (_c = keys_1.return) && _c.call(keys_1);
         } finally {
           if (e_4) throw e_4.error;
         }
       }
       this._stack.push(map);
       break;

      case BYTE_CODE.LOAD_METHOD:
       var obj = this._stack.pop();
       var idx = this.getExArg(ip);
       var name = curFunc.globals[idx];
       this._stack.push(this.loadMethod(obj, name));
       break;

      case BYTE_CODE.CALL_METHOD:
       var argn = this.getExArg(ip);
       var args = [];
       for (var i = 0; i < argn; i++) args.unshift(this._stack.pop());
       var func = this._stack.pop();
       var ret_3 = func.func.apply(func.obj, args);
       null !== ret_3 && this._stack.push(ret_3);
       break;

      case BYTE_CODE.UNARY_NEGATIVE:
       var v = this._stack.pop();
       this._stack.push(-v);
       break;

      case BYTE_CODE.UNARY_NOT:
       var n = this._stack.length - 1;
       this._stack[n] = !this._stack[n];
       break;

      case BYTE_CODE.IMPORT_NAME:
      case BYTE_CODE.IMPORT_STAR:
      case BYTE_CODE.NOP:
       break;

      case BYTE_CODE.BUILD_TUPLE:
       var n = this.getExArg(ip);
       var value = [];
       for (var i = 0; i < n; i++) value.unshift(this._stack.pop());
       this._stack.push({
         __pyType: PyType.Tuple,
         tuple: value
       });
       break;

      case BYTE_CODE.FORMAT_VALUE:
       var top = this._stack.pop();
       var str2 = top;
       var type1 = typeof top;
       "number" == type1 && (str2 = String(top));
       this._stack.push(str2);
       break;

      case BYTE_CODE.BUILD_STRING:
       var arr = [];
       var v = this.getExArg(ip);
       for (var i = 0; i < v; i++) arr.unshift(this._stack.pop());
       var str2 = arr.join("");
       this._stack.push(str2);
     }
   };
   PyManager.prototype.loadMethod = function(obj, name) {
     var func3 = obj[name];
     return {
       __pyType: PyType.Method_Function,
       func: obj[name],
       obj: obj
     };
   };
   PyManager.prototype.readByte = function() {
     var v = this._buffer[this._index];
     this._index++;
     return v;
   };
   PyManager.prototype.readInteger = function() {
     var b1 = this.readByte();
     var n = 0;
     var v = 0;
     for (var i = 7; i >= 0; i--) {
       var vv = 1 << i;
       if (0 == (b1 & vv)) break;
       v |= vv;
       n++;
     }
     b1 &= ~v;
     for (var i = 0; i < n; i++) {
       b1 <<= 8;
       b1 |= this.readByte();
     }
     return b1;
   };
   PyManager.prototype.readString = function() {
     var jsonStr = "";
     var i = this._index;
     while (true) {
       var v = this._buffer[i];
       if (0 == v) {
         i++;
         break;
       }
       var n = 0;
       if (0 != (128 & v)) {
         n++;
         if (0 != (192 & v)) {
           n++;
           0 != (32 & v) && n++;
         }
       }
       if (n > 0) {
         var flag = 255;
         for (var j = 0; j < n; j++) flag &= ~(1 << 7 - j);
         var val = flag & this._buffer[i];
         for (var j = 1; j < n; j++) {
           var v2 = this._buffer[i + j];
           val <<= 6;
           val |= 63 & v2;
         }
         jsonStr += String.fromCharCode(val);
         i += n - 1;
       } else jsonStr += String.fromCharCode(v);
       i++;
     }
     this._index = i;
     return jsonStr;
   };
   return PyManager;
 }();
const manager = new PyManager()

manager.loadBin({_buffer:buf})

 console.log(manager,'PyManager');
 



